<template>
	<view class="index">




		<view class="hot">

			<view class="goods">
				<view class="goodsitem" v-for="(item,index) in goods" :key='item.id'
					@click="toPage('/pages/goodsdetail/index?id='+item.id)">
					<view class="goodsimg">
						<image :src="getimg(item.logo_url)" mode="widthFix"></image>
					</view>
					<text class="name">{{item.name}}</text>
					<text class="price">零售价：￥<text class="pricenum">{{Number(item.price)}}</text></text>
					<text class="vipprice">会员价：￥{{Number(item.vip_price)}}</text>
				</view>

			</view>
		</view>
	</view>
</template>

<script>
	import {
		GoodsSearch
	} from '../../api/api.js'
	export default {
		data() {
			return {
				banner: [],
				goods: [],
				ti: [],
				text: ''
			}
		},
		onLoad(res) {
			this.text = res.search
			this.GoodsSearch()
		},
		methods: {
			GoodsSearch() {
				GoodsSearch({
					goodsname: this.text
				}).then(res => {
					console.log(res)
					this.goods = res.data.GoodsList
				})
			},
			toPage(url) {
				uni.navigateTo({
					url: url
				})
			},
			toTarPage(url) {
				uni.switchTab({
					url: url
				})
			},
			getimg(url) {
				return this.websiteUrl + url
			}
		}
	}
</script>

<style lang="scss">
	.index {
		background: #F7F7F7;
		padding-top: 30px;
	}

	.hot {


		.title {
			display: flex;
			justify-content: space-between;
			align-items: center;
			width: 90%;
			margin: 0 auto;
			border-left: 4px solid #1D3F2B;
			padding-left: 2%;
			background: #F7F7F7;

			.name {
				color: #1D3F2B;
				font-size: 30rpx;
				font-weight: bold;
			}

			.more {
				font-size: 12px;
				color: #999999;
			}
		}

		.goods {
			display: table;
			width: 100%;
			background: #F7F7F7;

			.goodsitem {
				display: flex;
				flex-direction: column;
				width: 45%;
				float: left;
				margin: 20rpx 2.5%;
				background: #fff;

				.goodsimg {
					width: 100%;

					image {
						width: 100%;
						border-radius: 8px;
					}
				}


				text {
					margin: 10rpx 0;
				}

				.name {
					font-size: 15px;
					width: 92%;
					overflow: hidden;
					white-space: nowrap;
					text-overflow: ellipsis;
					padding: 0 4%;
				}

				.price {
					color: #C79E76;
					font-size: 14px;
					padding-left: 5px;

					.pricenum {
						font-size: 18px;
					}
				}

				.vipprice {
					font-size: 14px;
					padding-left: 5px;
				}
			}
		}
	}
</style>
